import FlagBox from "@/components/FlagBox/index.vue";
import Vue from "vue";
let element = null;
let vNode = null;
export function show(parentNode, config) {
  let parent = document.querySelector(parentNode);
  if (vNode) {
    vNode.$destroy();
    vNode.$el.remove();
  }
  // parent.removeChild(element);
  element = document.createElement("div");
  element.setAttribute("id", "flagBox");

  let parentFirstChild = parent.childNodes[0];
  parent.insertBefore(element, parentFirstChild);
  vNode = new Vue({
    render: (h) => h(FlagBox, { props: { rectConfig: config } }),
  });
  vNode.$mount("#flagBox");

}
export function hide() {
  if (vNode) {
    vNode.$destroy();
    vNode.$el.remove();
  }
}

export default {
  show,
  hide,
};
